/******************************************************************************
 *                  Shanghai ChipON Micro-Electronic Co.,Ltd                  *
 ******************************************************************************
 *  $File Name$       : main.c                                         	      *
 *  $Author$          : ChipON AE/FAE Group                                   *
 *  $Data$            : 2021-07-8                                             *
 *  $Hard Version     : KF32A156-MINI-EVB_V1.2                                *
 *  $Description$     : This is a template project used by WWDG.			  *
 ******************************************************************************
 *  Copyright (C) by Shanghai ChipON Micro-Electronic Co.,Ltd                 *
 *  All rights reserved.                                                      *
 *                                                                            *
 *  This software is copyright protected and proprietary to                    *
 *  Shanghai ChipON Micro-Electronic Co.,Ltd.                                 *
 ******************************************************************************
 *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  *
 *                     		REVISON HISTORY                               	  *
 *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  *
 *  Data       Version  Author        Description                             *
 *  ~~~~~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  *
 *  2021-07-08 00.02.00 FAE Group     Version 2.0 update                      *
 *                                                                            *
 *                                                                            *
 *****************************************************************************/

/******************************************************************************
**                      		Include Files                                **
******************************************************************************/
#include "system_init.h"
#include "User_SysTick.h"
#include "User_wwdg.h"


/*******************************************************************************
**                     			main Functions 		             	     	  **
*******************************************************************************/
int main()
{
	/* Initialize the system clock */
	SystemInit(SYSCLK_FREQ);
	/* Setup SysTick Timer as delay function */
	systick_delay_init(SYSCLK_FREQ);
	/*Low frequency working frequency selection:1/1****************************/
	OSC_LFCK_Division_Config(LFCK_DIVISION_1);
	/*Select INTLF as LFCLK clock source***************************************/
	OSC_LFCK_Source_Config (LFCK_INPUT_INTLF);
	/*enable LFCLK*************************************************************/
	OSC_LFCK_Enable (TRUE);
	OSC_INTLF_Software_Enable(TRUE);
	
	GPIOInit_Output_Config(GPIOC_SFR,GPIO_PIN_MASK_6);

	/*user key input*/
	GPIOInit_Input_Config(GPIOC_SFR,GPIO_PIN_MASK_0);
	LED2_On();
	/*T=1/48M*48000=1ms,SCLK:48M*/
	SysTick_Configuration(48000);
	Systick_Delay(SYSTEM_DELAY_500MS);
	LED2_Off();
	Systick_Delay(SYSTEM_DELAY_500MS);
	LED2_On();
	WWDT_Config_TH(WWDT_Threshold);

	while(1)
	{
		#if WWDT_Enable_INT
		Systick_Delay(SYSTEM_DELAY_200MS);
		#else
		Systick_Delay(SYSTEM_DELAY_100MS);
		if(User_Key_Down()==SET)
		{
			WWDT_Clear();

		}
		#endif



	}		
}
/**
 *  @brief : Reports the name of the source file and the source line number
 *           where the assert_param error has occurred.
 *  @param in :	file pointer to the source file name
 * 	@param in :	line assert_param error line source number
 *  @param out :None
 *  @retval :None
 */
void check_failed(uint8_t* File, uint32_t Line)
{
	/* User can add his own implementation to report the file name and line number,
		ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

	/* Infinite loop */
	while(1)
	{
		;
	}
};
